﻿using DataProcess.Core.Model;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace DataProcess.Core.DataValidation
{
    public class SystemSettingValidation
    {
        public static ValidationResult AnalysisItemsValidation(List<AnalysisItemMapping> value)
        {
            string msg = string.Empty;
            var g = value.GroupBy(it => it.SourceName);
            foreach (var item in g)
            {
                if (item.Count() > 1)
                {
                    msg = $"源名称【{item.Key}】有重复项，请检查并更改后再提交";
                    break;
                }
            }
            if (!string.IsNullOrEmpty(msg)) return new ValidationResult(msg);
            return ValidationResult.Success;
        }
    }
}
